//
//  GenViewController.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/3/13.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#import "GenViewController.h"

#import "GenCustomCell.h"

#import "VisitingDetailViewController.h"
#import "CallDetailsViewController.h"
#import "NewGenJinVC.h"
@interface GenViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSMutableArray *_genArr;
    NSString *keStr;
}
@property(nonatomic,strong)UITableView *tabView;
@end

@implementation GenViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   self.title = @"待跟进";
    

    _genArr = [NSMutableArray arrayWithCapacity:0];
    _genArr = [_genDataDic objectForKey:@"data"];
    _tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, B_WIDTH, B_HEIGHT) style:UITableViewStylePlain];
    _tabView.delegate = self;
    _tabView.dataSource = self;
    _tabView.rowHeight = 50;
    _tabView.backgroundColor = BgColor;
    _tabView.separatorStyle = UITableViewCellSelectionStyleNone;//去掉cell的分割线
    [self.view addSubview:_tabView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_genConStr intValue];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"Cell";
    GenCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil)
    {
        cell = [[GenCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    if ([cell isKindOfClass:[GenCustomCell class]])
    {
        if (_genArr.count != 0)
        {
            NSDictionary *dict = [_genArr objectAtIndex:indexPath.row];
            
           
            [(GenCustomCell *)cell setUpGenJinCellWIthName:dict[@"name"] withSex:dict[@"sex"] withVisit:dict[@"yuqi_name"] withLast:dict[@"time"] withPhone:dict[@"phone"]];
            
            
        }
    }
      [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//取消点击
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    keStr = [[_genArr objectAtIndex:indexPath.row] objectForKey:@"yuqi_name"];
    CallDetailsViewController *callDetailVC = [[CallDetailsViewController alloc] init];
    
     NewGenJinVC *visitDetailVC = [[NewGenJinVC alloc] init];
    if ([keStr isEqualToString:@"来电客户"])
    {

        callDetailVC.callID = [[_genArr objectAtIndex:indexPath.row] objectForKey:@"id"];
        callDetailVC.isFirst = YES;
        [self.navigationController pushViewController:callDetailVC animated:NO];

    }
    else
    {
       
        visitDetailVC.genID = [[_genArr objectAtIndex:indexPath.row] objectForKey:@"id"];
        //visitDetailVC.isFirst = YES;
        [self.navigationController pushViewController:visitDetailVC animated:NO];
    }

    
    
}









- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
